<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"
%><%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"
%><%@ taglib prefix="security" uri="http://www.springframework.org/security/tags"
%><%@ taglib prefix="spring" uri="http://www.springframework.org/tags"
%><%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"
%><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"
%>
<head>
    <title><fmt:message key="contentlet" /></title>

    <link href="${pageContext.request.contextPath}/script/kissy/1.1.7/editor/theme/base-min.css" rel="stylesheet" type="text/css"/>

	<!--<link href="http://a.tbcdn.cn/s/kissy/1.1.7/editor/theme/base-min.css" rel="stylesheet"/>-->
	<!--[if lt IE 8]>
	<link href="http://a.tbcdn.cn/s/kissy/1.1.7/editor/theme/cool/editor-pkg-min.css" rel="stylesheet"/>
	<![endif]-->
	<!--[if gte IE 8]><!-->
    <link href="${pageContext.request.contextPath}/script/kissy/1.1.7/editor/theme/cool/editor-pkg-min-datauri.css" rel="stylesheet" type="text/css"/>
	<!--
	<script src="http://a.tbcdn.cn/s/kissy/1.1.7/??kissy-min.js,uibase/uibase-pkg-min.js,dd/dd-pkg-min.js,overlay/overlay-pkg-min.js,editor/editor-all-pkg-min.js"></script>
	-->
	<script src="${pageContext.request.contextPath}/script/kissy/1.1.7/kissy-min.js"></script>
	<script src="${pageContext.request.contextPath}/script/kissy/1.1.7/uibase/uibase-pkg-min.js"></script>
	<script src="${pageContext.request.contextPath}/script/kissy/1.1.7/dd/dd-pkg-min.js"></script>
	<script src="${pageContext.request.contextPath}/script/kissy/1.1.7/overlay/overlay-pkg-min.js"></script>
	<script src="${pageContext.request.contextPath}/script/kissy/1.1.7/editor/editor-all-pkg-min.js"></script>

	<!--<script src="http://a.tbcdn.cn/s/kissy/1.1.7/editor/biz/ext/editor-plugin-pkg-min.js"></script>-->
	<script src="${pageContext.request.contextPath}/script/kissy/1.1.7/editor/biz/ext/editor-plugin-pkg-min.js"></script>

</head>
<body>
	<c:url var="uploadImgUrl" value="/domain/contentlet/createFile">
		<c:param name="contentlet.inode" value="${contentletForm.contentlet.inode}"/>
	</c:url>
	<c:url var="updateUrl" value="/domain/contentlet/update">
		<c:param name="contentlet.inode" value="${contentletForm.contentlet.inode}"/>
	</c:url>
    <h1><fmt:message key="contentlet" /></h1>
	<script language="JavaScript">
	<!--
	KISSY.ready(function(S) {
		S.use('editor', function() {
			var KE = KISSY.Editor;
			var cfg = {
				attachForm:true,
				baseZIndex:10000,
				//自定义样式
				//customStyle:"p{color:purple;}",
				//自定义外部样式
				//customLink:["http://localhost/customLink.css","http://xx.com/y2.css"],
				//是否一开始自动聚焦
				//focus:true,
				pluginConfig: {
					"image":{
						upload:{
							serverUrl:"${uploadImgUrl}",
							serverParams:{
								waterMark:function() {
									return S.one("#ke_img_up_watermark_1")[0].checked;
								}
							},
							surfix:"png,jpg,jpeg,gif",
							fileInput:"flashUploadFiles",
							sizeLimit:1000,//k
							extraHtml:"<p style='margin-top:10px;'><input type='checkbox' id='ke_img_up_watermark_1' checked='checked'> 图片加水印，防止别人盗用</p>"
						}
					},
					"flash":{
						defaultWidth:"300",
						defaultHeight:"300"
					},
					"templates": [
						{
							demo: "模板1效果演示html"  ,
							html: "<div style='border:1px solid red'>模板1效果演示html</div><p></p>"
						},
						{
							demo: "模板2效果演示html",
							html: "<div style='border:1px solid red'>模板2效果演示html</div>"
						}
					],
					//"font-size":false,
					//"font-family":false,
					//"font-bold":false,
					// "font-italic":false,
					//"font-underline":false,

	//                "font-strikeThrough":{
	//                    style:{
	//                        element        : 'strike',
	//                        overrides    : [
	//                            {element        : 'span',
	//                                attributes         : { style:'text-decoration: line-through;' }},
	//                            { element : 's' },
	//                            { element : 'del' }
	//                        ]
	//                    }
	//                },
					"multi-upload":{
						serverUrl:"/code/upload/upload.jsp",
						serverParams:{
							waterMark:function() {
								return S.one("#ke_img_up_watermark_2")[0].checked;
							}
						},
						//previewSuffix:"_60x60",
						previewWidth:"80px",
						sizeLimit:1000//k,
						,numberLimit:15,
						extraHtml:"<p style='margin-top:10px;'>" +
								"<input type='checkbox' " +
								"style='vertical-align:middle;margin:0 5px;' " +
								"id='ke_img_up_watermark_2'>" +
								"<span style='vertical-align:middle;'>图片加水印，防止别人盗用</span></p>"
					},
					"video":{
						urlCfg:[
							{
								reg:/tudou\.com/i,
								url:"http://bangpai.daily.taobao.net/json/getTudouVideo.htm?" +
										"url=@url@&callback=@callback@"//"&rand=@rand@"
							}
						],
						urlTip:"请输入优酷网、土豆网、酷7网的视频播放页链接...",
						providers:[
							{
								reg:/youku\.com/i,
								width:480,
								height:400,
								detect:function(url) {
									var m = url.match(/id_([^.]+)\.html$/);
									if (m) {
										return "http://player.youku.com/player.php/sid/" + m[1] + "/v.swf";
									}
									m = url.match(/v_playlist\/([^.]+)\.html$/);
									if (m) {
										return;
										//return "http://player.youku.com/player.php/sid/" + m[1] + "/v.swf";
									}
									return url;
								}
							},
							{
								reg:/tudou\.com/i,
								width:480,
								height:400,
								detect:function(url) {
									return url;
								}
							},
							{
								reg:/ku6\.com/i,
								width:480,
								height:400,
								detect:function(url) {
									var m = url.match(/show[^\/]*\/([^.]+)\.html$/);
									if (m) {
										return "http://player.ku6.com/refer/" + m[1] + "/v.swf";
									}
									return url;
								}
							}/*,
							 {
							 reg:/taobaocdn\.com/i,
							 width:480,
							 height:400,
							 detect:function(url) {
							 return url;
							 }
							 }*/
						]
					},
					music:{
						//必须和网址url同域而不是类库同域
						musicPlayer:KE.Config.base + "music/niftyplayer.swf"
					},
					"draft":{
						interval:5,
						limit:10,
						helpHtml:  "<div " +
								"style='width:200px;'>" +
								"<div style='padding:5px;'>草稿箱能够自动保存您最新编辑的内容，" +
								"如果发现内容丢失，" +
								"请选择恢复编辑历史</div></div>"
					},
					"resize":{
						direction:["y"]
					},

					dragupload:{
						surfix:"png,jpg,jpeg,gif",
						fileInput:"flashUploadFiles",
						sizeLimit:1000,
						serverUrl:"${uploadImgUrl}",
						serverParams:{
							waterMark:function() {
								return true;
							}
						}
					}
				}
			};

			//if(1>2)
			function test() {
				window.editor2 = KE("#editor", S.clone(cfg)).use("elementpaths," +
						"sourcearea,preview," +
						"checkbox-sourcearea," +
						"templates,separator," +
						"undo,separator," +
						"removeformat,font,format,color,separator," +
						"list,indent," +
						"justify,separator,link," +
						"image,flash," +
						"video," +
						"music," +
						"xiami-music," +
						"smiley,separator,table,resize," +
						"draft," +
						"multi-upload," +
						"pagebreak,separator,maximize,dragupload");
			}
			test();

			window.editor2.ready(function () {
				KISSY.Event.on(window.editor2.document, "keydown", function (ev) {
					if (ev.keyCode == 13 && ev.ctrlKey) {
						window.editor2.sync();
						window.editor2.textarea[0].form.submit();
					}
				})
			});

			/**
			S.one('#destroy1').on("click", function(ev) {
				ev.halt();
				editor2.destroy();
				editor2 = null;
			});
			S.one('#recover1').on("click", function(ev) {
				ev.halt();
				if (!editor2) {
					test()
				}

			});
			**/
		});
	});
		
	//-->
	</script>
    
    <form:form action="${updateUrl}" id="contentletForm" modelAttribute="contentletForm" >
        <form:errors cssClass="error"/>
        <table>
            <form:hidden path="contentlet.inode"/>
            <tbody>
                <tr>
                    <th><fmt:message key="contentlet_title" /></th>
                    <td>
						<c:out value="${contentletForm.contentlet.title}"/>
                    </td>
                    <th><fmt:message key="contentlet_friendlyName" /></th>
                    <td>
						<c:out value="${contentletForm.contentlet.friendlyName}"/>
                    </td>
                </tr>
                <tr>
                    <th><fmt:message key="contentlet_structureInode" /></th>
                    <td>
						<c:out value="${contentletForm.contentlet.structureInode}"/>--<c:out value="${contentletForm.contentlet.structure.name}"/>
                    </td>
                    <th><fmt:message key="contentlet_folderInode" /></th>
                    <td>
						<c:out value="${contentletForm.contentlet.folderInode}"/>--<c:out value="${contentletForm.contentlet.folder.title}" />
                    </td>
                </tr>
				<tr>
					<th>自定义内容1</th>
					<td colspan="3">
						<div>        
						<textarea id="editor" name='contentlet.content' tabindex="0"
							style="width:100%;height:400px;margin:0 auto;">
						<c:out value="${contentletForm.contentlet.content}" escapeXml="false" />
						</textarea>
						</div>
					</td>
				</tr>
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="4">
                        <div class="buttons">

                            <button id="saveButton" class="ok" type="submit"><fmt:message key="label.form.submit"/></button>
                            <script type="text/javascript">
                                Spring.addDecoration(new Spring.ValidateAllDecoration({
                                    elementId:'saveButton',
                                    event:'onclick'
                                }));
                            </script>

                            <c:url var="showUrl" value="/domain/contentlet/show.action">
                                <c:param name="contentlet.inode" value="${contentletForm.contentlet.inode}"/>
                            </c:url>
                            <a href="${showUrl}"><span><fmt:message key="label.link.show"/></span></a>
                        </div>
                    </td>
                </tr>
            </tfoot>
        </table>
    </form:form>
</body>
